import React from 'react';
import SelectModal from '@alife/gcc-form-antd-mobile/es/components/SelectModal';

const PhoneSelect = (props) => {
  // SelectModal有个不显示placeholder的bug，处理一下
  const { value, defaultValue, mode = SelectModal.defaultProps.mode } = props;
  const _value = value || defaultValue;
  let key = 'normal';
  let finalMode = mode;
  if (!_value && (mode === 'single')) {
    key = 'placeholder';
    finalMode = 'multiple'; // 等于multiple可以渲染出placeholder
  }
  // 选了值之后利用key去重置SelectModal的state隐藏modal
  return <SelectModal key={key} {...props} mode={finalMode} />;

}

export default PhoneSelect;
